package com.yuanyefu.ModifyDefinition;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;

/**
 * Created by Administrator on 2017/9/17 0017.
 */
public class MessagePublisher implements ApplicationContextAware {
    private ApplicationContext context;
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
       this.context=applicationContext;
    }
    public void sendMessage(final String message){
        context.publishEvent(new ApplicationEvent(this) {
            @Override
            public String toString() {
                return message;
            }
        });
    }
}
